#!/bin/sh

# Do all the funky stuff:
cd quake3

if [ ! -d $HOME/lib ]
then
    if [ ! -e /usr/lib/libopenal.so.0 ]
    then
        echo "You don't seem to have openal installed. Aborting."
        exit
    fi 
else
   export USE_HOMEDIRLIBS=1
fi


make #> make_output 2>&1

if [ ! -d $COPYDIR ]
then
    echo "You need to define a copydir. Please input one here."
    read COPYDIR
fi

PLATFORM=$(uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]')
if [ $PLATFORM = "darwin" ]
then
  # Apple does some things a little differently...
  ARCH=$(uname -p | sed -e s/i.86/i386/)
else
  ARCH=$(uname -m | sed -e s/i.86/i386/)
fi

cd ..
rsync --exclude=*.svn* -r resources/genetic/* quake3/build/release-$PLATFORM-$ARCH/genetic/.
rsync --exclude=*.svn* -r resources/genetic/* quake3/build/release-$PLATFORM-$ARCH/baseq3/.
cp resources/run.sh quake3/build/release-$PLATFORM-$ARCH/run.sh


#make copyfiles #> make_copyfiles_output 2>&1 

